<template>
    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      @change="handleTableChange"
    >
    </a-table>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@/api/manage'

export default {
  name: 'PosMemberRefundlist',
  mixins: [JeecgListMixin],
  components: {},
  //接受父组件向子组件传递的数据
  props: ['memberId'],
  data() {
    return {
      description: '客户退款信息',
      disableMixinCreated: true,
      // 表头
      columns: [
        {
          title: '退单编号',
          dataIndex: 'refundNo',
          align: 'center',
        },
        {
          title: '订单号',
          dataIndex: 'orderNo',
          align: 'center',
        },
        {
          title: '退款时间',
          dataIndex: 'refundTime',
          align: 'center',
        },
        {
          title: '退款状态',
          dataIndex: 'refundBizStatusLabel',
          align: 'center',
        },
        {
          title: '消费门店',
          dataIndex: 'shopName',
          align: 'center',
        },
        {
          title: '退款金额',
          dataIndex: 'refundAmount',
          align: 'center',
        },
        {
          title: '退货原因',
          dataIndex: 'refundReason',
          align: 'center',
        },
      ],
      url: {
        list: '/cashier/posOrderRefund/list',
      },
    }
  },
  created() {
    this.loadData()
  },
  watch:{
    //子组件接收参数，并监听此值变化，一旦变化则初始化数据
    memberId(newVal,oldVal){
      this.dataSource = []
      console.log('===oldVal===', oldVal)
      console.log('===newVal===', newVal)
      this.loadData()
    }
  },
  methods: {
    loadData(arg) {
      if (arg === 1) {
        this.ipagination.current = 1
      }
      console.log('===memberId===', this.memberId)
      //主子表分开维护，生成的代码子表的分页改为真实的分页
      this.queryParam.memberId = this.memberId
      getAction(this.url.list, {
        memberId: this.memberId,
        refundBizStatus: 'REFUND_SUCC',
        pageNo: this.ipagination.current,
        pageSize: this.ipagination.pageSize,
      }).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records
          this.ipagination.total = res.result.total
        } else {
          this.dataSource = null
        }
      })
      //主子表分开维护，生成的代码子表的分页改为真实的分页
    },
  },
}
</script>
<style scoped>
</style>